//
//  PPBaseViewController.m
//  pickpic
//
//  Created by 胡文广 on 2017/3/26.
//  Copyright © 2017年 MicroDream. All rights reserved.
//

#import "PPBaseViewController.h"

@interface PPBaseViewController ()
@end

@implementation PPBaseViewController

- (void)popViewPreviousController{
    
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)dismissPreviousController{
    
    [self dismissViewControllerAnimated:YES completion:nil];
}
- (void)viewWillAppear:(BOOL)animated {
    
    [super viewWillAppear:animated];
    
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.automaticallyAdjustsScrollViewInsets = YES;
    self.edgesForExtendedLayout = UIRectEdgeTop;
    self.view.backgroundColor = [UIColor colorWithRGBHex:0xf2f2f2];

    
    UINavigationBar *navigationBar = self.navigationController.navigationBar;
    [navigationBar setBackgroundImage:[UIImage imageNamed:@"nav_bg"]
                       forBarPosition:UIBarPositionAny
                           barMetrics:UIBarMetricsDefault];
    [navigationBar setShadowImage:[UIImage new]];

}
- (void)setupBackItem{
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"nav_back"] style:UIBarButtonItemStylePlain target:self action:@selector(popViewPreviousController)];
    UIBarButtonItem * spaceItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
    //将宽度设为负值
    spaceItem.width = -2;
    
    if (IS_IPHONE_6_PLUS) {
        spaceItem.width = -6;
    }
    
    //将两个BarButtonItem都返回给NavigationItem
    spaceItem.tintColor = BLACK;
    leftItem.tintColor = BLACK;
    self.navigationItem.leftBarButtonItems = @[spaceItem,leftItem];
}

@end
